<template>
  <div>
    <nav-bar
      >
      <div slot="left">
        <button @click="backHome">返回</button>
        <!-- <img src="~assets\img\common\back.svg" alt=""> -->
      </div>
      <div slot="center" class="title">
        <div v-for="(item, index) in titles" 
            :key="index" 
            class="title-item"
            :class="{active: index == currentIndex}"
            @click="tabBarChange(index)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
// import NavBar from '../../../components/common/navbar/NavBar.vue'

export default {
  components: {
    NavBar,
  },
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0
    };
  },
  methods: {
    tabBarChange(index){
      this.currentIndex = index
    },
    backHome(){
      this.$router.back()
    },
  },
};
</script>

<style scoped>
.title {
  display: flex;
  font-size: 14px;
}

.title-item {
  flex: 1;
}

.active {
  color: var(--color-high-text);
}
</style>